Skip to main content

How to change working directory of a python program - Using built in OS Module

 This blogpost is all about finding your current working directory and changing according to your choice


Check current working directory for python program

Follow the code snippet below to find your current working directory. This is the path in which your python program is currently running.

import os
print(os.getcwd())


Change current working directory of your python program

Follow the code snippet below to accomplish the task.

import os
os.chdir('c://desired_folder')

This will change your current working directory path to your desired path 

Comments

Popular posts from this blog

[SOLVED] An AMP component 'script' tag is present, but unused - Search Console issue for wordpress website

I Encounter this issue " An AMP component 'script' tag is present, but unused." in my search console for a wordpress website.  I was using "Newspaper 9" wordpress theme with AMP enabled with the help of plugin provided by NEWSPAPER THEME. Everything was going good until i got this error. An AMP component 'script' tag is present, but unused. It was clear the error was due to a change in my website code. I recently got Adsense approval for my website and it was pretty clear that it was due to " AMP ADS ".  I think that my website was adsense approved a few days ago and this could be the reason that AMP-ADS were not setup properly. I used GOOGLE SITE KIT to implement Auto Ads as well as inserting the Ad-code for Adsense approval.  How I solved This Issue I tried many ways to implement amp-ads with the help of AMP Plugin provided by newspaper, Google Site kit. I also tried many Amp settings in my Adsense Dashboard. Luc...

How to make a private repository in Git Hub

  Step 1 is to create a gitignore file in that directory. So open Git Bash in the desired directory. Then use the command below to accomplish the task. Here you can add name of files or folders which you don't want to add in your github repository. Adding the file name or file directory name will simply ignore that file or file directory. touch .gitignore Step 2 is to Initialise. So use the command below to initialize. git init Step 3 is to add content to staging area. So use the command below to add all the content to staging area and prepare all the content to be added to your repository.  git add . Remember all the files except the file names added in the gitignore file will be added to the staging area. Step 4 is to make our first commit. So use the command below to make a commit. Here i called my first commit as "Initial Commit" you can call it "First Commit" or whatever you like. git commit -m "Initial Commit" Step 4 is an optional...